;; -*- lexical-binding: t -*-

;; (setq gc-cons-threshold (* 20 1024 1024))

;; 耗时：1.1 s。
(when (version< emacs-version "27.0")
  (package-initialize))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(TeX-DVI-via-PDFTeX t)
 '(TeX-PDF-mode t)
 '(TeX-electric-math '("$" . "$"))
 '(TeX-engine 'xetex)
 '(TeX-queue-command nil)
 '(ac-auto-show-menu 0.1)
 '(ac-auto-start 1)
 '(async-shell-command-buffer 'new-buffer)
 '(async-shell-command-display-buffer nil)
 '(bidi-paragraph-direction 'left-to-right)
 '(c-echo-syntactic-information-p t)
 '(calendar-latitude 36.80983445)
 '(calendar-longitude 117.99934387)
 '(chatgpt-shell-api-url-base "http://192.168.0.185:8000")
 '(chatgpt-shell-openai-key 111)
 '(column-number-mode t)
 '(company-idle-delay 0.1)
 '(company-minimum-prefix-length 1)
 '(connection-local-criteria-alist
   '(((:application vc-git) vc-git-connection-default-profile)
     ((:application tramp :protocol "kubernetes")
      tramp-kubernetes-connection-local-default-profile)
     ((:application eshell) eshell-connection-default-profile)
     ((:application tramp :protocol "flatpak")
      tramp-container-connection-local-default-flatpak-profile
      tramp-flatpak-connection-local-default-profile)
     ((:application tramp :protocol "scpx" :machine "pandorabox")
      remote-busybox)
     ((:application tramp :protocol "sshx" :machine "pandorabox")
      remote-busybox)
     ((:application tramp :protocol "scpx" :machine "E5tunnel")
      remote-bash)
     ((:application tramp :protocol "sshx" :machine "E5tunnel")
      remote-bash)
     ((:application tramp :protocol "scpx" :machine "E5") remote-bash)
     ((:application tramp :protocol "sshx" :machine "E5") remote-bash)
     ((:application tramp :protocol "scpx" :machine "E5wlan")
      remote-bash)
     ((:application tramp :protocol "sshx" :machine "E5wlan")
      remote-bash)
     ((:application tramp :protocol "scpx" :machine "E5internet")
      remote-bash)
     ((:application tramp :protocol "sshx" :machine "E5internet")
      remote-bash)
     ((:application tramp :protocol "scpx" :machine "kvm") remote-bash)
     ((:application tramp :protocol "sshx" :machine "kvm") remote-bash)
     ((:application tramp :protocol "scpx" :machine "bandwagon")
      remote-bash)
     ((:application tramp :protocol "sshx" :machine "bandwagon")
      remote-bash)
     ((:application tramp :protocol "scpx" :machine "sdf")
      remote-bash-sdf)
     ((:application tramp :protocol "sshx" :machine "sdf")
      remote-bash-sdf)
     ((:application tramp)
      tramp-connection-local-default-system-profile
      tramp-connection-local-default-shell-profile)))
 '(connection-local-profile-alist
   '((vc-git-connection-default-profile (vc-git--program-version))
     (tramp-flatpak-connection-local-default-profile
      (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin"
			 "/usr/bin" "/sbin" "/usr/sbin"
			 "/usr/local/bin" "/usr/local/sbin"
			 "/local/bin" "/local/freeware/bin"
			 "/local/gnu/bin" "/usr/freeware/bin"
			 "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin"
			 "/opt/sbin" "/opt/local/bin"))
     (tramp-kubernetes-connection-local-default-profile
      (tramp-config-check . tramp-kubernetes--current-context-data)
      (tramp-extra-expand-args 97
			       (tramp-kubernetes--container
				(car tramp-current-connection))
			       104
			       (tramp-kubernetes--pod
				(car tramp-current-connection))
			       120
			       (tramp-kubernetes--context-namespace
				(car tramp-current-connection))))
     (eshell-connection-default-profile (eshell-path-env-list))
     (tramp-container-connection-local-default-flatpak-profile
      (tramp-remote-path "/app/bin" tramp-default-remote-path "/bin"
			 "/usr/bin" "/sbin" "/usr/sbin"
			 "/usr/local/bin" "/usr/local/sbin"
			 "/local/bin" "/local/freeware/bin"
			 "/local/gnu/bin" "/usr/freeware/bin"
			 "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin"
			 "/opt/sbin" "/opt/local/bin"))
     (remote-bash-sdf (explicit-shell-file-name . "/usr/pkg/bin/bash")
		      (explicit-bash-args "-himBH"))
     (remote-busybox (explicit-shell-file-name . "/bin/sh")
		     (busybox . t))
     (remote-bash (explicit-shell-file-name . "/bin/bash")
		  (explicit-bash-args "-i"))
     (tramp-connection-local-darwin-ps-profile
      (tramp-process-attributes-ps-args "-acxww" "-o"
					"pid,uid,user,gid,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
					"-o" "state=abcde" "-o"
					"ppid,pgid,sess,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etime,pcpu,pmem,args")
      (tramp-process-attributes-ps-format (pid . number)
					  (euid . number)
					  (user . string)
					  (egid . number) (comm . 52)
					  (state . 5) (ppid . number)
					  (pgrp . number)
					  (sess . number)
					  (ttname . string)
					  (tpgid . number)
					  (minflt . number)
					  (majflt . number)
					  (time . tramp-ps-time)
					  (pri . number)
					  (nice . number)
					  (vsize . number)
					  (rss . number)
					  (etime . tramp-ps-time)
					  (pcpu . number)
					  (pmem . number) (args)))
     (tramp-connection-local-busybox-ps-profile
      (tramp-process-attributes-ps-args "-o"
					"pid,user,group,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
					"-o" "stat=abcde" "-o"
					"ppid,pgid,tty,time,nice,etime,args")
      (tramp-process-attributes-ps-format (pid . number)
					  (user . string)
					  (group . string) (comm . 52)
					  (state . 5) (ppid . number)
					  (pgrp . number)
					  (ttname . string)
					  (time . tramp-ps-time)
					  (nice . number)
					  (etime . tramp-ps-time)
					  (args)))
     (tramp-connection-local-bsd-ps-profile
      (tramp-process-attributes-ps-args "-acxww" "-o"
					"pid,euid,user,egid,egroup,comm=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
					"-o"
					"state,ppid,pgid,sid,tty,tpgid,minflt,majflt,time,pri,nice,vsz,rss,etimes,pcpu,pmem,args")
      (tramp-process-attributes-ps-format (pid . number)
					  (euid . number)
					  (user . string)
					  (egid . number)
					  (group . string) (comm . 52)
					  (state . string)
					  (ppid . number)
					  (pgrp . number)
					  (sess . number)
					  (ttname . string)
					  (tpgid . number)
					  (minflt . number)
					  (majflt . number)
					  (time . tramp-ps-time)
					  (pri . number)
					  (nice . number)
					  (vsize . number)
					  (rss . number)
					  (etime . number)
					  (pcpu . number)
					  (pmem . number) (args)))
     (tramp-connection-local-default-shell-profile
      (shell-file-name . "/bin/sh") (shell-command-switch . "-c"))
     (tramp-connection-local-default-system-profile
      (path-separator . ":") (null-device . "/dev/null"))))
 '(corfu-auto t)
 '(custom-safe-themes
   '("8aca557e9a17174d8f847fb02870cb2bb67f3b6e808e46c0e54a44e3e18e1020"
     "7e78a1030293619094ea6ae80a7579a562068087080e01c2b8b503b27900165c"
     "6a37be365d1d95fad2f4d185e51928c789ef7a4ccf17e7ca13ad63a8bf5b922f"
     "ff82ac6718ad6c69ddbd28f32c3544e8462c7c3d97afbe1a0c4a0773e48a96e2"
     default))
 '(delete-selection-mode t)
 '(describe-char-unidata-list
   '(name old-name general-category canonical-combining-class
	  decomposition decimal-digit-value digit-value numeric-value
	  mirrored iso-10646-comment uppercase lowercase titlecase))
 '(dired-listing-switches "-alh")
 '(dired-recursive-deletes 'always)
 '(dired-sort-menu-saved-config
   '((dired-actual-switches . "-alhS") (ls-lisp-ignore-case)
     (ls-lisp-dirs-first . t)))
 '(dired-use-ls-dired t)
 '(disaster-cc "gcc")
 '(disaster-cflags "-Ofast -march=native -g3 -std=c11")
 '(disaster-cxxflags "-Ofast -march=native -g3 -std=c++1y")
 '(disaster-objdump "objdump -d -M intel-mnemonic -Sl --no-show-raw-insn")
 '(display-buffer-alist '(("*shell*" display-buffer-same-window)))
 '(display-time-24hr-format t)
 '(display-time-mode t)
 '(doc-view-continuous t)
 '(doc-view-resolution 192)
 '(echo-keystrokes 0.1)
 '(ediff-custom-diff-options "-u")
 '(ediff-window-setup-function 'ediff-setup-windows-plain t)
 '(electric-pair-mode t)
 '(epg-gpg-program "/usr/bin/gpg")
 '(ess-eval-visibly 'nowait)
 '(font-lock-maximum-decoration t)
 '(gcmh-verbose t)
 '(gdb-many-windows t)
 '(gdb-show-main t)
 '(global-corfu-mode t)
 '(global-hl-line-mode t)
 '(global-prettify-symbols-mode t)
 '(global-semantic-decoration-mode t)
 '(global-semantic-highlight-func-mode t)
 '(global-semantic-idle-local-symbol-highlight-mode t nil (semantic/idle))
 '(global-semantic-idle-scheduler-mode t)
 '(global-semantic-idle-summary-mode t)
 '(global-semantic-show-parser-state-mode t)
 '(global-semantic-stickyfunc-mode nil)
 '(global-semanticdb-minor-mode t)
 '(gnuplot-process-name "pgnuplot")
 '(gnuplot-program "pgnuplot")
 '(google-translate-default-source-language "en")
 '(google-translate-default-target-language "zh-CN")
 '(grep-use-null-filename-separator t)
 '(help-at-pt-timer-delay 0.1)
 '(highlight-current-line-globally t)
 '(hscroll-margin 0)
 '(inferior-octave-program "/bin/octave")
 '(inferior-octave-prompt-read-only t)
 '(inferior-octave-startup-args '("-i" "--line-editing"))
 '(inhibit-startup-screen t)
 '(ispell-dictionary "en_US-large")
 '(ispell-local-dictionary-alist
   '(("en_US-large" "[[:alpha:]]" "[^[:alpha:]]" "['\31]" t
      ("-d" "en_US-large,en_US-med,en_US-chem") nil utf-8)))
 '(ispell-program-name "hunspell")
 '(js-indent-level 2)
 '(js2-basic-offset 2)
 '(js3-indent-level 2)
 '(js3-indent-tabs-mode t)
 '(kind-icon-default-face 'corfu-default)
 '(kind-icon-default-style
   '(:padding 0 :stroke 0 :margin 0 :radius 0 :height 0.75 :scale 0.75))
 '(langtool-default-language "en-US")
 '(langtool-mother-tongue "zh-CN")
 '(list-directory-verbose-switches "-l")
 '(load-prefer-newer t)
 '(magit-last-seen-setup-instructions "1.4.0" t)
 '(magit-repo-dirs '("~/repo"))
 '(make-backup-files nil)
 '(markdown-asymmetric-header nil)
 '(markdown-enable-math t)
 '(message-log-max 5000)
 '(minibuffer-prompt-properties
   '(read-only t point-entered minibuffer-avoid-prompt face
	       minibuffer-prompt))
 '(mouse-scroll-delay 0.15)
 '(multi-translate-sentence-backends '(bing))
 '(multi-translate-word-backends nil)
 '(native-comp-speed 3)
 '(no-redraw-on-reenter t)
 '(org-export-copy-to-kill-ring nil)
 '(org-export-html-footnote-format "<sup>[%s]</sup>")
 '(org-export-show-temporary-export-buffer nil)
 '(org-export-with-footnotes t)
 '(org-fold-core-style 'overlays)
 '(org-footnote-section "Footnotes:")
 '(org-footnote-tag-for-non-org-mode-files nil)
 '(org-html-doctype "html5")
 '(org-support-shift-select t)
 '(overline-margin 0)
 '(package-archives
   '(("gnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/gnu/")
     ("nongnu" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/nongnu/")
     ("melpa" . "https://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")))
 '(package-enable-at-startup nil)
 '(package-gnupghome-dir "/home/kel/.emacs.d/elpa/gnupg")
 '(package-selected-packages
   '(abl-mode ac-c-headers ac-dabbrev ac-etags ac-js2 ac-math ac-octave
	      academic-phrases aio alpha apel async auctex
	      auto-compile auto-complete auto-complete-auctex
	      auto-complete-pcmp auto-virtualenv bing-dict cape
	      chatgpt-shell chinese-word-at-point compat compile-angel
	      corfu csv-mode cygwin-mount dash dired-k dired-sort-menu
	      dired-sort-menu+ disaster dna-mode doom-themes dot-mode
	      edit-server ef-themes elpa-mirror elpher ess f fasm-mode
	      fast-scroll fic-mode flim gcmh ghub
	      gnu-elpa-keyring-update gnuplot-mode google-translate
	      hexo ht htmlize hydra hyperbole js-comint js2-mode
	      js2-refactor julia-mode kind-icon linum-relative
	      literate-calc-mode llama load-relative loc-changes log4e
	      lv magit magit-popup magit-section markdown-mode
	      math-symbol-lists memoize mew multiple-cursors mutt-mode
	      names nlinum nyan-mode oauth2 org pacfiles-mode packed
	      pandoc-mode pdf-tools php-mode poly-markdown polymode
	      popup pos-tip posframe powerline pyenv-mode python-mode
	      pyvenv-auto rainbow-delimiters rainbow-mode realgud rime
	      s sdcv semi shell-maker shimbun showtip simple-httpd
	      skewer-mode smart-compile smiles-mode srefactor svg
	      svg-clock svg-lib symon synonyms systemd tablist
	      test-simple transient treepy visual-fill-column vlf
	      w32-browser w32browser-dlgopen wanderlust with-editor
	      wordnut writegood-mode yaml-mode yaoddmuse yasnippet
	      youdao-dictionary zone-matrix))
 '(pdf-annot-default-annotation-properties
   '((t (label . "")) (text (color . "#ff0000") (icon . "Insert"))
     (highlight (color . "yellow")) (underline (color . "blue"))
     (squiggly (color . "orange")) (strike-out (color . "red"))))
 '(preview-TeX-style-dir "" t)
 '(preview-auto-cache-preamble t)
 '(preview-default-document-pt 25.0)
 '(preview-fast-conversion nil)
 '(preview-gs-options
   '("-q" "-dNOPAUSE" "-DNOPLATFONTS" "-dPrinted" "-dTextAlphaBits=4"
     "-dGraphicsAlphaBits=4"))
 '(preview-scale-function 'preview-scale-from-face)
 '(ps-font-size '(9 . 10.5))
 '(ps-lpr-switches
   '("-q" "-dNOPAUSE" "-dBATCH" "-sDEVICE=mswinpr2" "-sPAPERSIZE=a4"))
 '(ps-print-header nil)
 '(ps-printer-name t)
 '(python-shell-virtualenv-root nil)
 '(recentf-max-saved-items 200)
 '(recentf-mode t)
 '(rime-show-candidate 'posframe)
 '(safe-local-variable-values
   '((shell-file-name . "/bin/bash") (explicit-bash-args "-himBH")
     (explicit-shell-file-name . "/usr/pkg/bin/bash")
     (explicit-bash-args "-i")
     (explicit-shell-file-name . "/bin/bash")))
 '(search-whitespace-regexp "[-_ \12\15\11]+")
 '(semantic-decoration-styles
   '(("semantic-decoration-on-includes" . t)
     ("semantic-decoration-on-protected-members")
     ("semantic-decoration-on-private-members")
     ("semantic-tag-boundary" . t)))
 '(semantic-default-submodes
   '(global-semantic-decoration-mode global-semantic-idle-scheduler-mode
				     global-semanticdb-minor-mode
				     global-semantic-idle-summary-mode))
 '(semantic-idle-work-update-headers-flag t)
 '(send-mail-function 'smtpmail-send-it)
 '(sh-basic-offset 8)
 '(sh-indentation 8)
 '(show-paren-mode t)
 '(shr-color-visible-luminance-min 95)
 '(size-indication-mode t)
 '(smart-compile-alist
   '((emacs-lisp-mode emacs-lisp-byte-compile)
     (html-mode browse-url-of-buffer)
     (nxhtml-mode browse-url-of-buffer)
     (html-helper-mode browse-url-of-buffer) (octave-mode run-octave)
     ("\\.c\\'"
      . "gcc -Wall -fopt-info -Ofast -march=native -std=c11 %f -lm -o %n")
     ("\\.[Cc]+[Pp]*\\'"
      . "g++ -Wall -fopt-info -Ofast -march=native -std=c++11 %f -lm -o %n")
     ("\\.java\\'" . "javac %f") ("\\.php\\'" . "php -l %f")
     ("\\.f90\\'" . "gfortran %f -o %n")
     ("\\.[Ff]\\'" . "gfortran %f -o %n")
     ("\\.cron\\(tab\\)?\\'" . "crontab %f") ("\\.tex\\'" tex-file)
     ("\\.texi\\'" . "makeinfo %f")
     ("\\.\\(md\\|markdown\\)\\'" . "make -f ~/repo/Makefile %n.docx")
     (text-mode . "pandoc %f -f markdown -o %n.docx -s")
     ("\\.mp\\'" . "mptopdf %f") ("\\.pl\\'" . "perl -cw %f")
     ("\\.rb\\'" . "ruby -cw %f")))
 '(synonyms-cache-file "~/.emacs.d/mthesaur.txt.cache")
 '(synonyms-file "~/.emacs.d/mthesaur.txt")
 '(tab-always-indent nil)
 '(text-scale-mode-step 1.04)
 '(timer-max-repeats 1)
 '(tool-bar-mode nil)
 '(tooltip-delay 1.5)
 '(tooltip-hide-delay 60)
 '(tooltip-short-delay 0.7)
 '(tramp-completion-reread-directory-timeout nil)
 '(tramp-default-host "KAEL")
 '(tramp-default-method "scpx")
 '(tramp-local-host-regexp "\\`\\(127\\.0\\.0\\.1\\|::1\\|KAEL\\|localhost6?\\)\\'")
 '(uniquify-buffer-name-style 'forward nil (uniquify))
 '(visible-bell t)
 '(vlfi-batch-size 1048576)
 '(wl-quicksearch-folder "%INBOX:chriszheng99/clear@127.0.0.1:993!"))

(unless (daemonp)
  (server-start))

;; (set-language-environment "UTF-8")
;; (prefer-coding-system 'utf-8-unix)

;; 键绑定，耗时：0.2 s。
(load "~/.emacs.d/.init/my-key-bindings")

;; MS-Windows相关设置，耗时：0.1 s。
(when (string-equal system-type "windows-nt")
  (load "~/.emacs.d/.init/common-win"))

;; 一般的设置，耗时：0.4 s。
(load "~/.emacs.d/.init/common-settings")

;; keyboard macros
(load "~/.emacs.d/.init/.kmacros")

;; 一些函数及键绑定，耗时：0.1 s。
(load "~/.emacs.d/.init/some-functions")

;; 补全的设置，耗时：0.1 s。

;; (load "~/.emacs.d/.init/my-completion")
;; (when (fboundp 'auto-complete)
;;   (load "~/.emacs.d/.init/auto-complete-settings"))

;; C语言编程，耗时：0 s。
(load "~/.emacs.d/.init/for-C-language")

;; (load "~/.emacs.d/.init/for-org-mode")

;; (load-theme 'my-wheatgrass t)

;; test
;; (load "~/.emacs.d/.init/test")

;; Global settings (defaults)
;; (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
;;       doom-themes-enable-italic t) ; if nil, italics is universally disabled

;; (assq-delete-all 'diredp-dir-name doom-themes-common-faces)
;; (setf (cdr (assq 'diredp-dir-name doom-themes-common-faces)) '(:foreground functions :weight 'bold))

;; (doom-themes--apply-faces doom-themes-common-faces)

;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
;; may have their own settings.

;; (load-theme 'doom-Iosvkem t)

;; (doom-themes-set-faces 'doom-Iosvkem '(diredp-dir-name :inherit font-lock-function-name-face))

;; Enable flashing mode-line on errors
;; (doom-themes-visual-bell-config)

(when (or (display-graphic-p) (daemonp))
  (when (and (require 'alpha) (featurep 'alpha))
    (transparency-set-value 85)
    ;; 字体设置
    (load "~/.emacs.d/.init/font-settings")))

(put 'narrow-to-region 'disabled nil)
(put 'dired-find-alternate-file 'disabled nil)
(put 'upcase-region 'disabled nil)
(put 'timer-list 'disabled nil)
(put 'downcase-region 'disabled nil)

;; Use a hook so the message doesn't get clobbered by other messages.
;; (require 'doom-themes)
(require 'ef-themes)
(add-hook 'emacs-startup-hook
          (lambda ()
	    ;; (load-theme 'doom-outrun-electric t)
	    ;; (doom-themes-set-faces 'doom-outrun-electric
	    ;;   '(markdown-code-face :background bg-alt :extend t))
	    (load-theme 'ef-bio t)
            (message "Emacs ready in %s with %d garbage collections."
                     (format "%.2f seconds"
                             (float-time
                              (time-subtract after-init-time before-init-time)))
                     gcs-done)))

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(corfu-default ((t (:background "#191a1b" :height 0.8))))
 '(diredp-omit-file-name ((t (:inherit diredp-ignored-file-name))))
 '(hl-line ((t (:background "#002435"))))
 '(variable-pitch ((t (:family "Calibri Light")))))
